<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/favicon.ico">
    <link rel="stylesheet" href="lib/layui-v2.5.4/css/layui.css" media="all">
    <script src="js/common/xm-select.js"></script>
    <link rel="stylesheet" href="css/layuimini.css" media="all">
    <link rel="stylesheet" href="css/public.css" media="all">
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <style id="layuimini-bg-color">
    </style>
</head>
<body class="layui-layout-body layuimini-all">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header header">
        <div class="layui-logo">
            <a href="javascript:;" data-load-page="page/index_croe.html"
               data-tip="在线工具箱" class="layui-menu-tips"><h1>后台管理</h1></a>
        </div>
        <a><div class="layuimini-tool">
            <i class="layui-icon layui-icon-shrink-right" data-side-fold="1"></i></div></a>
        <ul class="layui-nav layui-layout-left layui-header-menu layui-header-pc-menu mobile layui-hide-xs">
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="https://zoodt.com" target="_blank" data-tip="前台首页">
                    <i class="layui-icon-home layui-icon" ></i>
                </a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:;" data-tip="更新后台菜单" class="refs_menu"><i class="layui-icon layui-icon-refresh"></i></a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:;" data-tip="重建我的权限缓存" class="refs_pris"><i class="layui-icon layui-icon-auz"></i></a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:;"  class="login-out">
                    <i class="layui-icon-logout layui-icon" style="margin-right: 25px;"></i>
                </a>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll layui-left-menu">
        </div>
    </div>
    <div class="layui-body">
            <div class="layui-card layuimini-page-header layui-hide-xs layui-hide">
                <div class="layui-breadcrumb" id="layuimini-page-header">
                    <a><cite>菜单管理</cite></a>
                </div>
            </div>
            <div class="layuimini-content-page">
            </div>
        </div>
</div>
<script src="lib/layui-v2.5.4/layui.js" charset="utf-8"></script>
<script src="js/lay-config.js" charset="utf-8"></script>
<script src="js/common/common.js"></script>
<script src="js/common/ace.js"></script>

<script>
    layui.use(['element','layuimini','vCache','http','table','form','util','tree','treeTable'], function () {
                window.http = layui.http
                window.vCache = layui.vCache
                window.layuimini = layui.layuimini
                window.form = layui.form
                window.table = layui.table
                window.$ = layui.jquery
                window.openBox = null
                window.tb = null
                window.util = layui.util
                window.tree = layui.tree
                window.element = layui.element;
                window.treeTable = layui.treeTable
                table.set({
                    headers:{'X-token':vCache.sGet('X-token') || vCache.lGet('X-token')},
                    page:true,
                    limit:15,
                    skin: 'line',
                    size:'lg',
                    limits:[15],
                    cellMinWidth: 120,
                });
                layuimini.config.dev = false
                let MenuData = vCache.lGet('menu_data') ;
                layuimini.initDevice();
                layuimini.side_fold(vCache.sGet('side_fold_is_show'),$('[data-side-fold]'))
                if( !MenuData ) {
                    layer.alert('请求菜单出错！');
                    setTimeout(function () {
                        vCache.sRm();vCache.lRm();
                        window.location = 'l.html';
                    },200)
                } else  {
                    layuimini.initMenu(MenuData)
                }
            const load_url = vCache.sGet('load_url') || vCache.lGet('load_url') ||
                 vCache.lGet('group_data.login_url') || 'page/index_normal.html';
            layuimini.initConten( load_url );
            $('.layui-logo').find('a').attr('data-load-page',load_url)
                form.verify({
               aplha:[
               /^[a-z_]+$/g,
               '必须是小写字母和下划线'
               ]
           });
        window.search_key = null;
        window.search_reg = function ( key ,str){
            if( !key || !str) return;
            const reg = new RegExp("(" + key + ")", "g");
           return str.toString().replace(reg,'<b class="red">$1</b>')

        }
        $('.login-out').on("click", function () {
            layer.confirm('确定退出？',{icon:3},function(){
                http.get('/admin/login/logout.htm').done( res => {
                    vCache.sRm();vCache.lRm();
                    window.location = 'l.html';
                })

            })
        });
        $(document).on('click','[data-load-page]',function(){
            const page = $(this).attr('data-load-page');
            $('.layuimini-content-page').load(page);
            vCache.lSet('load_url',page)
        });
        $('.refs_menu').click(function () {
            http.get('/admin/role_menu/clear.htm').done(function(res){
                if( res.code === 200 ){
                    let d = vCache.sGet('menu_data'),c = 1;
                    if( !d || d === false) {
                        c = 2;
                        d = vCache.lGet('menu_data')
                    }
                    if( typeof d == 'object' && Object.keys(d).length > 0){
                        if( c === 1 ){
                            vCache.sSet('menu_data',res.result);
                        } else {
                            vCache.lSet('menu_data',res.result);
                        }
                    } else {
                        layer.alert('菜单设置失败！');
                        return ;
                    }
                    setTimeout(() => {
                        window.location.reload()
                    }, 800);
                }
                layer.msg(res.msg);
            })
        });
        $('.refs_pris').click(function () {
            http.get('/admin/pri/build_my_pris.htm').done(function(res){
                layer.msg(res.msg)
            })
        });
    });
</script>
</body>
</html>
